package com.huabo.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Created by Jackie Liu on 2017/4/3.
 */
//@Component
public class SpringContextHelper implements ApplicationContextAware{

    //private static WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();

    private static ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext ac) throws BeansException {
        applicationContext = ac;
    }

    public static <T> T getBean(Class<T> clazz) {
        return applicationContext.getBean(clazz);
    }
}
